#include "helpwid.h"
#include <fstream>
#include <QDebug>
#include <QVBoxLayout>
HelpWid::HelpWid(QWidget *parent) : QWidget(parent)
{
    this->setWindowTitle("帮助文档");
    QVBoxLayout *vlayout = new QVBoxLayout(this);
    resize(900,600);
    this->titleLab = new QLabel("帮助文档",this);
    this->textLab = new QLabel("123",this);

    vlayout->addWidget(this->titleLab);
    vlayout->addWidget(textLab);
    readHelpFile();

    QFont font("楷体",16);
    QFont fontDesc("楷体",12);
    this->textLab->setWordWrap(true);
    this->textLab->setAlignment(Qt::AlignTop);
    this->textLab->setFont(fontDesc);
    this->titleLab->setMaximumHeight(height()*0.2);
    this->titleLab->setAlignment(Qt::AlignCenter);
    this->titleLab->setFont(font);
}

void HelpWid::readHelpFile()
{
    std::fstream in("d://help.txt",std::ios::in);
    std::string all;
    while(in.peek()!=EOF)
    {
        std::string line;
        std::getline(in,line);
        all += line;
        all += "\n";
    }
    this->textLab->setText(QString::fromLocal8Bit(all.c_str()));
    in.close();
}
